
/**
 * This controller is invoqued when a new user is disconnected in the application.
 * @author eKameleon
 */
if ( ewhiteboard.controller.application.DisconnectApplication == undefined ) 
{

	/**
	 * Creates a new DisconnectApplication instance. 
	 */
	ewhiteboard.controller.application.DisconnectApplication = function () 
	{
		//		
	}
	
	/**
	 * @extends andromeda.controller.AbstractController
	 */
	proto = ewhiteboard.controller.application.DisconnectApplication.extend( andromeda.controller.AbstractController ) ;

	/**
	 * Handles the event.
	 */
	proto.handleEvent = function ( e /*ApplicationEvent*/ ) 
	{
		LOGGER.debug( this + " handleEvent." ) ;
		
		var client /*Client*/ = e.client ;
		
		if ( client != null )
		{
			
			var id              = client.id ;
			var name /*String*/ = client.name ;
			
			if ( id != null ) // use the UserVO hack
			{
				
				var users /*MapModel*/ = andromeda.model.ModelCollector.get( MODEL_LIST.USER_MODEL ) ;
				try
				{	
					var vo /*UserVO*/ = users.getVO( id ) ;
					users.removeVO( vo ) ;
					LOGGER.debug( this + " remove the user in the model success : " + vo )  ;
				}
				catch( e /*Error*/ )
				{
					LOGGER.warn( this + " remove the user in the model failed : " + e.toString() )  ;
				}
				
			}
		}
		else
		{
			LOGGER.debug( this + " : " + e.getType() ) ;
		}
	}
	
	delete proto ;
	
}